<?php
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
global $base_url;

global $theme_path;

drupal_add_css($theme_path.'/css/mosaico.css');

$arrObjView = $view->result;
$grid = array("a", "b", "c", "d", "b", "b", "b","e");

?>
<div class="mosaico-box">
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <?php
                foreach($arrObjView as $intChave => $objResultado):
                    
                    $obj        = $objResultado->_field_data["nid"]["entity"];
                
                    $titulo     = $objResultado->node_title;
                    $bairro     = $objResultado->field_field_bairro[0]["rendered"]["#title"];
                    $desc       = $obj->field_descricao_teaser["und"][0]["value"];
                    
                    $situacao   = $objResultado->field_field_situacao_da_obra[0]["rendered"]["#title"];
                    
                    $area_inicial = $objResultado->field_field_area_inicial[0]['rendered']['#markup'];
                    $area_final     = $objResultado->field_field_area_final[0]['rendered']['#markup'];
                    
                    if(!empty($area_inicial))
                        $emp        = 'de '.$area_inicial.' a '.$area_final;
                    else
                        $emp        = 'de '.$area_final;
                    
                    $img_uri    = $objResultado->field_field_imagem_teaser[0]['rendered']['#item']['uri'];
                    
                    switch($grid[$intChave]){
                        case "a":
                            $style = "540x200";
                            break;
                        case "b":
                            $style = "280x200";
                            break;
                        case "c":
                            $style = "284x412";
                            break;
                        case "d":
                            $style = "284x412";
                            break;
                        case "e":
                            $style = "576x200";
                            break;
                    }
                    
                    $img_url    = image_style_url($style,$img_uri);
                    
                    //a = 540x200
                    //b = 280x200
                    //c = 284x412
                    
                    $strUrl = drupal_get_path_alias('node/'.$objResultado->nid);
                    
                ?>
                <div class="grid grid_<?php print($grid[$intChave]); ?>" style="background-image:url(<?php print($img_url); ?>); ">
                    <a href="<?php print($strUrl); ?>">
                        <span class="details">
                        <div class="category"><?php print($situacao); ?></div>	
                        <h3><?php print($titulo); ?></h3>
                        <!-- <div class="show">Conheça</div> -->
                        <ul>
                            <li><span><i class="ico-home-location"></i><?php print($bairro); ?></span></li>
                            <li><span><i class="ico-home-room"></i><?php print($desc); ?></span></li>
                            <li><span><i class="ico-home-lenght"></i><?php print($emp); ?></span></li>
                        </ul>
                        </span>
                    <img src="<?php print($img_url); ?>" alt="">
                    </a>
                </div>
                <?php
                endforeach;
                ?>
            </div>
        </div>
    </div>
</div>